//
//  @ Project : Galaxy Star Trading System
//  @ File Name : FrozenHelper.h
//  @ Date : 2014/9/5
//  @ Author :
//
//

#if !defined(_CFROZENHELPER_H_H)
#define _CFROZENHELPER_H_H

#include "DataBase.h"


namespace GSTrader
{
	namespace TradeService
	{
		class CFrozenHelper
		{
		public:
			CFrozenHelper(CDataBase* pDataBase);
			virtual ~CFrozenHelper();

			bool OnRetOrder(COrderTable* pOrder, TotalFrozenCursor& tfCursor, CAccountInstrument* pAccountInstrument);
			bool OnRetTrade(COrderTable* pOrder, CTradeTable* pTrade, TotalFrozenCursor& tfCursor, CAccountInstrument* pAccountInstrument);

			bool OnRetOrder(AccountDataCursor& accountData, OrderCursor& orderCursor, CAccountInstrument* pAccountInstrument);
			bool OnRetTrade(AccountDataCursor& accountData, OrderCursor& orderCursor, TradeCursor& tradeCursor, CAccountInstrument* pAccountInstrument);

			bool AddOrderFrozen(COrderFrozenTable* pOrder, TotalFrozenCursor& totalFrozenCursor);
			bool DeleteOrderFrozen(int nOrderId, TotalFrozenCursor& totalFrozenCursor);

		public:
			CDataBase*		 m_pDataBase;
			CSettleHelper* m_pSettleHelper;
			CDBCommon*	 m_pDBCommon;
		};

		class CPrepareFrozenHelper
		{
		public:
			CPrepareFrozenHelper(CDataBase* pDataBase);
			virtual ~CPrepareFrozenHelper();

			bool OnNewOrder(CInputOrderTable* pOrder, PrepareForzenCursor& pfCursor);
			bool OnOrderError(int nOrderId);
			bool OnRetOrder(int nOrderId);

			bool DeleteOrderFrozen(int nOrderId);
			int GetForzenQty(int nProviderId, int nInstrumentId, int nSide, int nHegde);
		public:
			CDataBase*	m_pDataBase;
			CDBCommon*	m_pDBCommon;
		};
	}

}

#endif //_CFROZENHELPER_H_H